package main

import "fmt"

// Author : CSR丶WARRIOR
// Time ： 2020/10/13  21:32
// TOOLS : GoLand
// FILENAME : SliceIntercept.go
// STATEMENT: 切片截取操作

func main() {
	test4()
}

func test1() {
	s := []int{3, 5, 6, 7, 8, 9}
	s1 := s[1:3:5]
	fmt.Println(s1)      //[5 6]
	fmt.Println(len(s1)) //2,表示元素的个数
	fmt.Println(cap(s1)) // 4 ,表示切片容量
}

func test2() {
	var s []int = []int{3, 5, 6, 7, 8, 9}
	s1 := s[:]
	fmt.Println(s1)      //[3 5 6 7 8 9]
	fmt.Println(len(s1)) //6
	fmt.Println(cap(s1)) //6
}

func test3() {
	var s []int = []int{3, 5, 6, 7, 8, 9}
	s1 := s[2:]
	fmt.Println(s1)      //[6 7 8 9]
	fmt.Println(len(s1)) //4
	fmt.Println(cap(s1)) //4
}

func test4() {
	var s []int = []int{3, 5, 6, 7, 8, 9}
	s1 := s[2:6]
	fmt.Println(s1)      //[7 8 9]
	fmt.Println(len(s1)) //4
	fmt.Println(cap(s1)) //4
}

func test5() {
	var s []int = []int{3, 5, 6, 7, 8, 9}
	s1 := s[:3]
	fmt.Println(s1)      //[3 5 6]
	fmt.Println(len(s1)) //3
	fmt.Println(cap(s1)) //6
}
